/*
 * Main.fx
 *
 * Created on Nov 21, 2010, 4:19:06 PM
 */

package katrinebanko;

import javafx.util.Math;
import java.util.ArrayList;
import java.util.Collections;
import javafx.scene.text.Text;
import javafx.scene.text.Font;

/**
 * @author casper
 */
public class Main {

    var talListe = new ArrayList();
    var sorteretTalListe = new ArrayList();
    var sorteretListe:String = "";
    var usorteretListe:String = "";
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:main
    public-read def font: javafx.scene.text.Font = javafx.scene.text.Font {
        name: "Verdana"
        size: 100.0
        embolden: false
    }
    
    public-read def dropShadow: javafx.scene.effect.DropShadow = javafx.scene.effect.DropShadow {
        input: null
        blurType: javafx.scene.effect.BlurType.TWO_PASS_BOX
        offsetX: 5.0
        offsetY: 5.0
        radius: 20.0
        spread: 0.0
    }
    
    public-read def text: javafx.scene.text.Text = javafx.scene.text.Text {
        managed: false
        layoutX: bind scene.width / 2.5
        layoutY: bind scene.height / 2
        scaleX: bind scene.width/200
        scaleY: bind scene.height/150
        effect: dropShadow
        fill: javafx.scene.paint.Color.BLACK
        textAlignment: null
        textOrigin: null
        boundsType: null
        font: font
        content: ""
    }
    
    public-read def font2: javafx.scene.text.Font = javafx.scene.text.Font {
        size: 24.0
    }
    
    public-read def text3: javafx.scene.text.Text = javafx.scene.text.Text {
        layoutX: 25.0
        layoutY: bind scene.height-130
        effect: null
        fill: javafx.scene.paint.Color.BLACK
        wrappingWidth: bind scene.width-50
        font: font2
        content: ""
    }
    
    public-read def text2: javafx.scene.text.Text = javafx.scene.text.Text {
        layoutX: 25.0
        layoutY: 25.0
        fill: javafx.scene.paint.Color.BLACK
        wrappingWidth: bind scene.width-50
        font: font2
        content: ""
    }
    
    def __layoutInfo_button: javafx.scene.layout.LayoutInfo = javafx.scene.layout.LayoutInfo {
        width: 120.0
        height: 40.0
    }
    public-read def button: javafx.scene.control.Button = javafx.scene.control.Button {
        layoutX: 10.0
        layoutY: bind scene.height-50
        layoutInfo: __layoutInfo_button
        text: "Nyt tal"
        font: font2
        action: nytTal
    }
    
    public-read def font3: javafx.scene.text.Font = javafx.scene.text.Font {
        size: 24.0
    }
    
    def __layoutInfo_button2: javafx.scene.layout.LayoutInfo = javafx.scene.layout.LayoutInfo {
        width: 120.0
        height: 40.0
    }
    public-read def button2: javafx.scene.control.Button = javafx.scene.control.Button {
        layoutX: bind scene.width - 130
        layoutY: bind scene.height-50
        layoutInfo: __layoutInfo_button2
        text: "Nyt spil"
        font: font3
        action: nytSpil
    }
    
    public-read def scene: javafx.scene.Scene = javafx.scene.Scene {
        width: 480.0
        height: 320.0
        content: getDesignRootNodes ()
        camera: null
        fill: javafx.scene.paint.Color.WHITE
    }
    
    public-read def currentState: org.netbeans.javafx.design.DesignState = org.netbeans.javafx.design.DesignState {
    }
    
    public function getDesignRootNodes (): javafx.scene.Node[] {
        [ button, text, text2, text3, button2, ]
    }
    
    public function getDesignScene (): javafx.scene.Scene {
        scene
    }
    // </editor-fold>//GEN-END:main

    function nytSpil(): Void {
        talListe.clear();
        sorteretTalListe.clear();
        text.content = "";
        text2.content = "";
        text3.content = "";
    }

    function nytTal(): Void {
        var rand = Math.random()*100;
        var tal = rand.intValue();
        while ((tal==0 or tal>90 or talListe.contains(tal)) and talListe.size()<90) {
            rand = Math.random()*100;
            tal = rand.intValue();
        }
        if (talListe.size()<90) {
            talListe.add(tal);
            sorteretTalListe.add(tal);
            Collections.sort(sorteretTalListe);
            sorteretListe = sorteretTalListe.toString().substring(1, sorteretTalListe.toString().length()-1);
            sorteretListe = sorteretListe.replaceAll(" ", "");
            text3.content = sorteretListe;
            usorteretListe = talListe.toString().substring(1, talListe.toString().length()-1);
            usorteretListe = usorteretListe.replaceAll(" ", "");
            text2.content = usorteretListe;
            text.content = "{tal}";
        }
    }
}

function run (): Void {
    var design = Main {};

    javafx.stage.Stage {
        title: "KatrineBanko"
        scene: design.getDesignScene ()
    }
}
